package com.ljyh.cygnus.screens.viewmodel

import androidx.lifecycle.viewModelScope
import com.ljyh.cygnus.model.CommandUiState
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow

class DataViewModel : BaseViewModel() {
    private val _uiState = MutableStateFlow<CommandUiState>(CommandUiState.Idle)
    val uiState: StateFlow<CommandUiState> = _uiState.asStateFlow()

    // 强行开启
    fun enableData() {
        executeRootCommands(
            _uiState,
            "svc data enable",
            "iptables -D OUTPUT -o rmnet_data0 -j DROP || true",
            "iptables -D INPUT -i rmnet_data0 -j DROP || true"

        )
    }

    // 强行关闭
    fun disableData() {
        executeRootCommands(
            _uiState,
            "svc data disable",
            "iptables -D OUTPUT -o rmnet_data0 -j DROP || true",
            "iptables -A OUTPUT -o rmnet_data0 -j DROP",
            "iptables -D INPUT -i rmnet_data0 -j DROP || true",
            "iptables -A INPUT -i rmnet_data0 -j DROP"

        )
    }
    // 不管控
    fun defaultData() {
        executeRootCommands(
            _uiState,
            "svc data enable",
            "iptables -D OUTPUT -o rmnet_data0 -j DROP || true",
            "iptables -D INPUT -i rmnet_data0 -j DROP || true"

        )
    }


}